package cz.fit.vutbr.pis2012.augeaswh.managers;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import cz.fit.vutbr.pis2012.augeaswh.persistence.Order;
import cz.fit.vutbr.pis2012.augeaswh.persistence.OrdersStockType;
import cz.fit.vutbr.pis2012.augeaswh.persistence.StockType;

@Stateless
public class OrdersManager {
	@PersistenceContext
	EntityManager em;
	
	@SuppressWarnings("unchecked")
	public List<Order> getOrders() {
		return em.createQuery("SELECT o FROM Order o WHERE o.processDate is null").getResultList();
	}
	
	public void save(Order o) {
		em.merge(o);
	}
	
	public void delete(Order o) {
		em.remove(em.merge(o));
	}
}
